package com.ruoyi.web.controller.business;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ruoyi.business.pojo.dto.MiniUserEditGradeDto;
import com.ruoyi.ruoyi.business.pojo.dto.MiniUserEditStateDto;
import com.ruoyi.ruoyi.business.pojo.dto.MiniUserListDto;
import com.ruoyi.ruoyi.business.pojo.vo.MiniUserListVo;
import com.ruoyi.ruoyi.business.service.smo.MiniUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * ClassName：MiniUserController
 * Package：com.ruoyi.web.controller.business
 * Description：小程序用户
 *
 * @Author：fpy
 * @Create：2025/5/8 - 16:07
 * @Version：v1.0
 */
@RestController
@RequestMapping("/miniuser")
public class MiniUserController extends BaseController {
    @Resource
    private MiniUserService miniUserService;

    /**
     * 小程序用户列表
     *
     * @param: dto
     * @return: com.ruoyi.common.core.domain.AjaxResult<com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.ruoyi.ruoyi.business.pojo.vo.MiniUserListVo>>
     * @author: fpy
     * @date: 2025/5/8 16:11
    **/
    @PostMapping("/list")
    @PreAuthorize("@ss.hasPermi('business:miniuser:list')")
    public AjaxResult<Page<MiniUserListVo>> list(@RequestBody @Validated MiniUserListDto dto) {
        return miniUserService.list(startPage(), dto);
    }

    /**
     * 修改状态
     *
     * @param: dto
     * @return: com.ruoyi.common.core.domain.AjaxResult
     * @author: fpy
     * @date: 2025/5/8 16:32
    **/
    @PostMapping("/edit/state")
    @PreAuthorize("@ss.hasPermi('business:miniuser:edit')")
    public AjaxResult editState(@RequestBody @Validated MiniUserEditStateDto dto) {
        return miniUserService.editState(dto);
    }

    /**
     * 修改会员等级
     *
     * @param: dto
     * @return: com.ruoyi.common.core.domain.AjaxResult
     * @author: fpy
     * @date: 2025/5/8 16:35
    **/
    @PostMapping("/edit/grade")
    @PreAuthorize("@ss.hasPermi('business:miniuser:edit')")
    public AjaxResult editGrade(@RequestBody @Validated MiniUserEditGradeDto dto) {
        return miniUserService.editGrade(dto);
    }
}
